import 'package:appflutterhomeschool/provider/provider_widget.dart';
import 'package:appflutterhomeschool/res/styles.dart';
import 'package:appflutterhomeschool/route/application.dart';
import 'package:appflutterhomeschool/route/routes.dart';
import 'package:appflutterhomeschool/ui/dialogs/prompt_dialog_widgets.dart';
import 'package:appflutterhomeschool/ui/widgets/button_widget.dart';
import 'package:appflutterhomeschool/ui/widgets/my_app_bar.dart';
import 'package:appflutterhomeschool/view_model/letter/system_notification_view_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

///用户： ninetailedfox
///时间： 2020/6/22
///邮箱： 1037438704@qq.com
///功能： 系统通知页面

class SystemNotificationPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ProviderWidget<SystemNotificationViewModel>(
      model: SystemNotificationViewModel(context),
      onModelReady: (value) => value.initView(),
      builder: (context, viewModel, child) {
        return Scaffold(
          appBar: MyAppBar2(title: "系统通知"),
          body: ListView.builder(
            shrinkWrap: true,
            itemCount: 10,
            itemBuilder: (context, index) {
              return Container(
                margin: EdgeInsets.only(
                  left: ScreenUtil().setWidth(43),
                  right: ScreenUtil().setWidth(43),
                  top: ScreenUtil().setWidth(52),
                ),
                padding: EdgeInsets.only(bottom: ScreenUtil().setWidth(33)),
                decoration: BoxDecoration(
                    border: Border(
                        bottom: BorderSide(color: Colors.grey, width: 0.3))),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Text("系统通知", style: TextStyles.textDarkBold43),
                    SizedBox(height: ScreenUtil().setWidth(25)),
                    Text("2020-02-20 23:21", style: TextStyles.textGray27),
                    SizedBox(height: ScreenUtil().setWidth(51)),
                    Text.rich(TextSpan(children: [
                      TextSpan(text: "伊伊", style: TextStyles.textBlue34),
                      TextSpan(
                          text: "作为小明家长申请加入【高一一班】",
                          style: TextStyles.textDark34),
                    ])),
                    Visibility(
                      visible: viewModel.identity,
                      child: Padding(
                        padding:
                            EdgeInsets.only(top: ScreenUtil().setWidth(33)),
                        child: Text("已同意", style: TextStyles.textRed34),
                      ),
                    ),
                    Visibility(
                      visible: viewModel.identity,
                      child: Padding(
                        padding:
                            EdgeInsets.only(top: ScreenUtil().setWidth(33)),
                        child: Text("拒绝原因：班级内没有该学生，请核实后加入",
                            style: TextStyles.textGray27),
                      ),
                    ),
                    Visibility(
                      visible: viewModel.identity,
                      child: Row(
                        crossAxisAlignment: CrossAxisAlignment.center,
                        mainAxisAlignment: MainAxisAlignment.end,
                        children: <Widget>[
                          ButtonWidget().outlineButtonWidget(
                              buttonName: "拒绝加入",
                              onPressed: () {
                                PromptDialogWidgets(viewModel.me)
                                    .refuseButtomDialog(onTap: () {
                                  FocusScope.of(context).requestFocus(FocusNode());
                                  Application().navigatePushToPage(
                                      context, Routes.applyPage, {"pageTag" : 1});
                                });
                              }),
                          SizedBox(width: ScreenUtil().setWidth(34)),
                          ButtonWidget().ellipseButtonWidget(
                              buttonName: "同意加入", onPressed: () {}),
                        ],
                      ),
                    )
                  ],
                ),
              );
            },
          ),
        );
      },
    );
  }
}
